package controy

import (
	"encoding/json"
	"fmt"
	"net/http"
)

type Employment struct {
	Company string `json:"company"`
	Title   string `json:"title"`
}

type Foo struct {
	Name string     `json:"name"`
	Age  int        `json:"age"`
	Job  Employment `json:"job"`
}

func Testjson(w http.ResponseWriter, r *http.Request) {
	data := []byte(`{"name": "John Doe", "age": 25, "job": {"company": "ABC", "title": "Engineer"}}`)
	var f Foo

	json.Unmarshal(data, &f)
	fmt.Printf("%s is %d years old.\n", f.Name, f.Age)

	output, _ := json.Marshal(&f)
	fmt.Println(string(output))
}
